﻿using System;
using System.Net;
using System.Windows;

namespace TestingWpfApplication
{
    /// <summary>
    /// Interaktionslogik für Window1.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            iPv4TextBox1.Address = System.Net.IPAddress.Parse("192.168.0.123");
            iPv6TextBox1.Address = System.Net.IPAddress.Parse("2001:db8:0:8d3:0:8a2e:70:7344");
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            textBox1.Text = iPv4TextBox1.Address.ToString();
        }

        private void button2_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                iPv4TextBox1.Address = IPAddress.Parse(textBox1.Text);
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
        }

        private void button3_Click(object sender, RoutedEventArgs e)
        {
            textBox2.Text = iPv6TextBox1.Address.ToString();
        }

        private void button4_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                iPv6TextBox1.Address = IPAddress.Parse(textBox2.Text);
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
        }
    }
}
